package avicit.bdp.dgs.mdm.utils.enums;

/**
 * 主数据码段类型
 *
 * @author mayi
 */
public enum MdmCodeTypeEnum {
  GD("GD", "固定码"),
  // TZ("TZ", "特征码"),
  LS("LS", "流水码"),
  RQ("RQ", "日期码");
  // YY("YY", "引用码"),
  // RL("RL", "日期流水码"),
  // TL("TL", "特征流水码"),
  // QL("QL", "区间流水码");

  private final String code;

  private final String desc;

  MdmCodeTypeEnum(String code, String desc) {
    this.code = code;
    this.desc = desc;
  }

  public String getCode() {
    return code;
  }

  public String getDesc() {
    return desc;
  }

  public static String getDescByCode(String code) {
    if (code != null) {
      MdmCodeTypeEnum[] values = MdmCodeTypeEnum.values();
      for (MdmCodeTypeEnum item : values) {
        if (item.getCode().equals(code)) {
          return item.getDesc();
        }
      }
    }

    return null;
  }

  public static MdmCodeTypeEnum getTypeByCode(String code) {
    if (code != null) {
      MdmCodeTypeEnum[] values = MdmCodeTypeEnum.values();
      for (MdmCodeTypeEnum item : values) {
        if (item.getCode().equals(code)) {
          return item;
        }
      }
    }
    return null;
  }
}
